<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>用户管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		var arrayObj = new Array();		
		$(document).ready(function() {
			dotext("1","小王","天津局","环境科学");
			dotext("2","老李","天津局","环境科学");
			dotext("3","小孙","天津局","环境科学");			
			$("#btnExport").click(function(){
				top.$.jBox.confirm("确认要导出用户数据吗？","系统提示",function(v,h,f){
					if(v=="ok"){
						$("#searchForm").attr("action","${ctx}/sys/user/export");
						$("#searchForm").submit();
					}
				},{buttonsFocus:1});
				top.$('.jbox-body .jbox-icon').css('top','55px');
			});
			$("#btnImport").click(function(){
				$.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
					bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
			});
		});
		function page(n,s){
			if(n) $("#pageNo").val(n);
			if(s) $("#pageSize").val(s);
			$("#searchForm").attr("action","${ctx}/sys/user/list_zj");
			$("#searchForm").submit();
	    	return false;
	    }
		function dotext(id,name,office,zy){
			var result= $.inArray(id, arrayObj)
			if(result>=0){ 
			}else{ 
				arrayObj.push(id);
				$('.data-result').append("<span class=\"svae_box aui-titlespan\" data-code=\"" + id + "\" data-name=\"" +name+"-"+office+"-"+zy+ "\" onclick=\"removespan_area(this)\">" + name+"-"+office+"-"+zy + "<i>×<\/i><\/span>");
			}
		}
		function removespan_area(spanthis) {
			//alert($(spanthis).data("code"));
			$.each(arrayObj,function(index,item){  
				if(item==$(spanthis).data("code")){
					arrayObj.splice(index,1);
				}
			});
			$('a[data-code=' + $(spanthis).data("code") + ']').removeClass('d-item-active');
			if ($('a[data-code=' + $(spanthis).data("code") + ']').length > 0) {
				if ($('a[data-code=' + $(spanthis).data("code") + ']').attr("class").indexOf('data-all') > 0) {
					$('a[data-code=' + $(spanthis).data("code") + ']').parent('li').nextAll('li').find('a').css({ 'color': '#0077b3', 'a.d-item-active:hover': '#fff', 'cursor': 'pointer' });
					$('a[data-code=' + $(spanthis).data("code") + ']').parent('li').nextAll("li").find('a').attr("onclick", "selectProvince(\'sub\',this,\'\')");
		
				}
			}
			$(spanthis).remove();
		}		
	</script>
</head>
<body>
	<div id="importBox" class="hide">
		<form id="importForm" action="${ctx}/sys/user/import" method="post" enctype="multipart/form-data"
			class="form-search" style="padding-left:20px;text-align:center;" onSubmit="loading('正在导入，请稍等...');"><br/>
			<input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
			<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
			<a href="${ctx}/sys/user/import/template">下载模板</a>
		</form>
	</div>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/sys/user/list_zj">执法人员选择</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="user" action="${ctx}/sys/user/list_zj" method="post" class="breadcrumb form-search ">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<sys:tableSort id="orderBy" name="orderBy" value="${page.orderBy}" callback="page();"/>
		<ul class="ul-form">
			<li><label>归属局：</label><sys:treeselect id="company" name="company.id" value="${user.company.id}" labelName="company.name" labelValue="${user.company.name}" 
				title="归属局" url="/sys/office/treeData?type=1" cssClass="input-small" allowClear="true"/></li>
			<li><label>专&nbsp;&nbsp;&nbsp;业：</label><form:input path="zy" htmlEscape="false" maxlength="50" class="input-medium"/></li>
			<li class="clearfix"></li>
			<li><label>归属机构：</label><sys:treeselect id="office" name="office.id" value="${user.office.id}" labelName="office.name" labelValue="${user.office.name}" 
				title="归属机构" url="/sys/office/treeData?type=2" cssClass="input-small" allowClear="true" notAllowSelectParent="false"/></li>
			<li><label>姓&nbsp;&nbsp;&nbsp;名：</label><form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/></li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" onClick="return page();"/>
<!--				<input id="btnExport" class="btn btn-primary" type="button" value="导出"/>
				<input id="btnImport" class="btn btn-primary" type="button" value="导入"/>--></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
<!--        	<th>选择</th>-->
        	<th class="sort-column name">姓名</th>
            <th>归属局</th>
            <th>归属机构</th>
            <th>专业</th>
            <th>电话</th>
            <th>手机</th>
<!--            <shiro:hasPermission name="sys:user:edit"><th>操作</th></shiro:hasPermission></tr>-->
        </thead>
		<tbody>
		<c:forEach items="${page.list}" var="user">
			<tr>
            	<!--<td width="10px" align="center"><input id="could" name="could" type="checkbox" value="" onClick="javascript:dotext('${user.id}','${user.name}','${user.office.name}','${user.zy}')"/></td>-->
            	<td><a href="javascript:void(0)" onClick="javascript:dotext('${user.id}','${user.name}','${user.office.name}','${user.zy}')">${user.name}</a></td>
				<td>${user.company.name}</td>
				<td>${user.office.name}</td>
				<td>${fns:getDictLabels(user.zy, 'sys_user_zy', '')}</td>
				<td>${user.phone}</td>
				<td>${user.mobile}</td><%--
				<td>${user.roleNames}</td> --%>
<!--				<shiro:hasPermission name="sys:user:edit"><td>
    				<a href="${ctx}/sys/user/form_zj?id=${user.id}">加入执法人员库</a>
				</td></shiro:hasPermission>-->
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	<br>
	<form:form id="inputForm" modelAttribute="user" action="${ctx}/jcxx/drJcxx/zfjh_list" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">已选执法人员：</label>
			<div class="controls">
				<div class="data-result"></div>
			</div>
		</div>  
		<div class="form-actions">
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保存"/>&nbsp;
			<input id="btnCancel" class="btn" type="button" value="返 回" onClick="history.go(-1)"/>
		</div>         
    </form:form>     
</body>
</html>